#include<bits/stdc++.h>
using namespace std;
const int maxn = 99999;
int tr[maxn<<2],lz[maxn],n;
void pushup(int rt)
{
	tr[rt]=tr[rt<<1]+tr[rt<<1|1];
}
void pushdown(int rt,int len)
{
	if(lz[rt])
	{
		lz[rt<<1]+=lz[rt];lz[rt<<1|1]+=lz[rt];
		tr[rt<<1]+=lz[rt]*(len-(len>>1));
		tr[rt<<1|1]+=lz[rt]*(len>>1);
		lz[rt]=0;
	}
}
void build(int rt,int l,int r)
{
	if(l==r){cin>>tr[rt];return;}
	int mid=l+r>>1;
	build(rt<<1,l,mid);
	build(rt<<1|1,mid+1,r);
	pushup(rt);
}
void modify(int rt,int L,int R,int l,int r,int val)
{
	if(l<=L && r>=R){tr[rt]+=(R-L+1)*val;lz[rt]+=val;return;}
	pushdown(rt,R-L+1);
	int mid=L+R>>1;
	if(r<=mid)modify(rt<<1,L,mid,l,r,val);
	else if(l>mid)modify(rt<<1|1,mid+1,R,l,r,val);
	else{
		modify(rt<<1,L,mid,l,mid,val);
		modify(rt<<1|1,mid+1,R,mid+1,r,val);
	}
	pushup(rt);
}
int query(int rt,int L,int R,int l,int r)
{
	if(l<=L && r>=R)return tr[rt];
	pushdown(rt,R-L+1);
	int mid=L+R>>1;
	if(r<=mid)return query(rt<<1,L,mid,l,r);
	else if(l>mid)return query(rt<<1|1,mid+1,R,l,r);
	else return query(rt<<1,L,mid,l,mid)+query(rt<<1|1,mid+1,R,mid+1,r);
}
int main()
{
	cin>>n;
	build(1,1,n);
	while(1)
	{
		int a,b,c,d;
		cin>>a>>b>>c;
		if(a==1)
			cout<<query(1,1,n,b,c)<<endl;
		else{
			cin>>d;
			modify(1,1,n,b,c,d);
		}
	}
	return 0;
}
